package cn.wolfcode.p2p.business.domain;

import cn.wolfcode.p2p.base.domain.BaseDomain;
import cn.wolfcode.p2p.util.Constant;
import lombok.Getter;
import lombok.Setter;

import java.math.BigDecimal;

/**
 * 体验金模型
 */
@Setter
@Getter
public class ExpAccount extends BaseDomain {
    /**
     * 版本
     */
    private Integer version = 0;
    /**
     * 可用余额
     */
    private BigDecimal usableAmount = Constant.ZERO;
    /**
     * 冻结余额
     */
    private BigDecimal freezedAmount = Constant.ZERO;
    /**
     * 欠系统体验金
     */
    private BigDecimal unReturnExpAmount = Constant.ZERO;

    /**
     * 用户体验金账户总额
     */

    public BigDecimal getTotalAmount(){
        return usableAmount.add(freezedAmount);
    }

    /**
     * 添加可用余额
     */
    public void addUsableAmount(BigDecimal usableAmount){
        BigDecimal temp = this.usableAmount.add(usableAmount);
        this.usableAmount = temp;

    }
    /**
     * 减少可用余额
     */
    public void subtractUsableAmount(BigDecimal usableAmount){
        BigDecimal temp = this.usableAmount.subtract(usableAmount);
        this.usableAmount = temp;

    }
    /**
     * 添加冻结资金
     */
    public void addFreezedAmount(BigDecimal freezedAmount){
        BigDecimal temp = this.freezedAmount.add(freezedAmount);
        this.freezedAmount = temp;

    }
    /**
     * 减少冻结资金
     */
    public void subtractFreezedAmount(BigDecimal freezedAmount){
        BigDecimal temp = this.freezedAmount.subtract(freezedAmount);
        this.freezedAmount = temp;

    }

}